package main

import (
	"asy-cache/router"
	"fmt"
	"gopkg.in/yaml.v3"
	"io/ioutil"
	"strconv"
)

type Conf struct {
	Ip          string   `yaml: "ip"`
	Port        string   `yaml: "port"`
	VirtualNode string   `yaml: "virtualnode"`
	MaxSpace    string   `yaml: "maxspace"`
	Center      []string `yaml: "center"`
}

func main() {

	// 读取配置文件
	confPath := "./conf.yaml"
	ReConf, err := ioutil.ReadFile(confPath)
	if err != nil {
		fmt.Print(err)
	}
	// 解析配置文件
	var config Conf
	yaml.Unmarshal(ReConf, &config)

	fmt.Println("配置信息：", config)

	virtualNode, _ := strconv.Atoi(config.VirtualNode)
	maxSpace, _ := strconv.ParseInt(config.MaxSpace, 10, 64)

	router.InitRouter(config.Ip, config.Port, virtualNode, config.Center, maxSpace)
}
